using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using WCF = System.Web.Configuration.WebConfigurationManager;

/// <summary>
/// Summary description for ChuoiDangKy_Data
/// </summary>
public class ChuoiDangKy_Data
{
    public void insert(string ChuoiDangKy)
    {
        string connectionString = WCF.ConnectionStrings["gets_SPDG"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        if (connection.State == ConnectionState.Open)
            connection.Close();
        connection.Open();
        //SqlDataAdapter adapter = new SqlDataAdapter();
        try
        {
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "insert_ChuoiDangKy";
            Command.Connection = connection;
            Command.CommandType = CommandType.StoredProcedure;
            Command.Parameters.Add("@ChuoiDangKy", SqlDbType.NVarChar, 50);
            Command.Parameters["@ChuoiDangKy"].Value = ChuoiDangKy;
            SqlDataReader reader;
            reader = Command.ExecuteReader();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

    public bool KiemTra(string ChuoiDangKy)
    {
        string connectionString = WCF.ConnectionStrings["gets_SPDG"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        if (connection.State == ConnectionState.Open)
            connection.Close();
        connection.Open();
         SqlDataReader reader;
        //SqlDataAdapter adapter = new SqlDataAdapter();
        try
        {
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "KiemTraChuoiDangKy";
            Command.Connection = connection;
            Command.CommandType = CommandType.StoredProcedure;
            Command.Parameters.Add("@ChuoiDangKy", SqlDbType.NVarChar, 10);
            Command.Parameters["@ChuoiDangKy"].Value = ChuoiDangKy;
            reader = Command.ExecuteReader();
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
            return false;
        }
        if (reader.HasRows)
            return true;
        return false;
    }
	public ChuoiDangKy_Data()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
